import aip
import requests
import json,jsonpath

nip_date = {
    'AppID' : '15573315',
    'API_Key' : 'GN84DYHpvzVma1zAfGvl7OT9',
    'Secret_Key' : 'kx61VvTX69apNq7GL5fdyw3d5hSYIr1G',
}



def main():
    addr = aip.AipNlp(appId = nip_date['AppID'], apiKey= nip_date['API_Key'], secretKey= nip_date['Secret_Key'] )
    addr_url = 'http://2019.ip138.com/ic.asp'
    response = requests.get(url = addr_url)
    response.encoding = 'gbk'
    # print(response.text)
    stext = response.text[response.text.find('来自：')+3:response.text.find('</center>')]
    print(stext)
    result = addr.lexer(stext)
    result = jsonpath.jsonpath(result,'$..items[?(@.ne=="LOC")][basic_words][0]')
    print(result[-1])
if __name__ == "__main__":
    main()